package com.iqismart.shorturl.exception;

import java.io.Serializable;

/**
 * @Description
 * @Auther sty
 * @createTime 2019/10/14 01:38
 */
public class BaseException extends RuntimeException implements Serializable {
    public Integer code;
    public String message;
    public String description;

    public BaseException(GlobalExceptionType globalExceptionType) {
        this.code = globalExceptionType.code;
        this.message = globalExceptionType.message;
        this.description = globalExceptionType.description;
    }

    public static BaseException fail(String message) {
        return new BaseException(-1, message);
    }

    public static void failAndThrow(String message) {
        throw new BaseException(-1, message);
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BaseException() {
    }

    public BaseException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BaseException(int code, String message, String description) {
        super(message);
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }
}
